This connector provides read and write access to the directories and folders within a Subversion repository, providing that content in the form of nt:file and nt:folder nodes. This source considers a workspace name to be the path to the directory on the repository's root directory location that represents the root of that workspace (e.g., "trunk" or "branches"). New workspaces can be created, as long as the names represent valid existing directories within the SVN repository.
The SvnRepositorySource class provides a number of JavaBean properties that control its behavior:
Property
|
Description
|
cachePolicy
|
Optional property that, if used, defines the cache policy for this repository source. When not used, this source will not define a specific duration for caching information.
|
creatingWorkspaceAllowed
|
Optional property that defines whether clients can create additional workspaces. The default value is "true".
|
defaultWorkspaceName
|
Optional property that, if used, specifies the name of the workspace to use when no workspace name is specified in an operation. If not specified, "trunk" is used. Each workspace name is treated as a path relative to the SVN repository being exposed. For example, given a repository root URL of "http://acme.com/repo/", a workspace name of "trunk" will map to "http://acme.com/repo/trunk".
|
name
|
Required property that specifies the name of the repository source, which is used by the RepositoryService when obtaining a RepositoryConnection by name.
|
nodeCachePolicy
|
Optional property that, if used, defines the cache policy to use for caching nodes within the connector.
|
password
|
The password that should be used to establish a connection to the repository. This is not required if the URL represents an anonymous SVN repository address.
|
predefinedWorkspaceNames
|
Optional property that, if used, defines names of the workspaces that are predefined and need not be created before being used. This can be coupled with a "false" value for the "creatingWorkspaceAllowed" property to allow only the use of only predefined workspaces.
|
retryLimit
|
Optional property that, if used, defines the number of times that any single operation on a RepositoryConnection to this source should be retried following a communication failure. The default value is '0'.
|
repositoryRootURL
|
Required property that should be set with the URL to the Subversion repository.
|
username
|
The username that should be used to establish a connection to the repository. This is not required if the URL represents an anonymous SVN repository address.
|
One way to configure the Subversion connector is to create JcrConfiguration instance with a repository source that uses the SvnRepositorySource class. For example:
JcrConfiguration config = ...
config.repositorySource("SVN Store")
.usingClass(SVNRepositorySource.class)
.setDescription("The ModeShape SVN repository (anonymous access)")
.setProperty("repositoryRootUrl", "http://anonsvn.jboss.org/repos/modeshape");
.setProperty("defaultWorkspaceName", "trunk");
.setProperty("predefinedWorkspaceNames", new String[] {"trunk","tags" });
Another way to configure the Subversion connector is to create JcrConfiguration instance and load an XML configuration file that contains a repository source that uses the SvnRepositorySource class. For example a file named configRepository.xml can be created with these contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!--
Define the sources for the content. These sources are directly accessible using the
ModeShape-specific Graph API. In fact, this is how the ModeShape JCR implementation works. You
can think of these as being similar to JDBC DataSource objects, except that they expose
graph content via the Graph API instead of records via SQL or JDBC.
-->
<mode:sources jcr:primaryType="nt:unstructured">
<!--
The 'SVN Store' repository is an Subversion source with one workspace (although others could
be defined).
-->
<mode:source jcr:name="SVN Store"
mode:classname="org.modeshape.connector.svn.SVNRepositorySource"
mode:description="The ModeShape SVN repository (anonymous access)"
mode:repositoryRootUrl="http://anonsvn.jboss.org/repos/modeshape"
mode:defaultWorkspaceName="trunk"
mode:defaultWorkspaceName="default" >
<mode:predefinedWorkspaceNames>tags</mode:predefinedWorkspaceNames>
<mode:predefinedWorkspaceNames>trunk</mode:predefinedWorkspaceNames>
<!--
If desired, specify a cache policy that caches items in memory for 5 minutes (300 s).
This fragment can be left out if the connector should not cache any content.
-->
<mode:cachePolicy jcr:name="nodeCachePolicy"
mode:classname="org.modeshape.graph.connector.base.cache.InMemoryNodeCache$PathCachePolicy"
mode:timeToLive="300" />
</mode:source>
</mode:sources>
<!-- MIME type detectors and JCR repositories would be defined below -->
</configuration>
The configuration can then be loaded from Java like this:
JcrConfiguration config = new JcrConfiguration().loadFrom("/configRepository.xml");